home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / scm / turtlgr.lha / scm / grtest.scm next >
Encoding:
Text File  |  1992-10-13  |  1.9 KB  |  83 lines

  1.  
  2. ; This is a quick hack to test the graphics primitives.
  3. ; The SLIB scheme library is needed for random.
  4. ; IMHO, the syntax of `do' in scheme is horrible!
  5. ; - sjm
  6.  
  7. (define (grtest)
  8.   (require 'random) ; needs SLIB
  9.   (graphics-mode!)
  10.  
  11.   (display "testing draw-to") (newline)
  12.   (clear-graphics!)
  13.   (goto-center!)
  14.   (do ((x 0 (+ x 3)))
  15.       ((> x (max-x)) 0)
  16.     (set-color! (remainder (/ x 3) (max-color)))
  17.     (draw-to x 0)
  18.     (draw-to x (max-y))
  19.   )
  20.  
  21.   (do ((y 0 (+ y 3)))
  22.       ((> y (max-y)) 0)
  23.     (set-color! (remainder (/ y 3) (max-color)))
  24.     (goto-center!)
  25.     (draw-to! 0 y)
  26.     (goto-center!)
  27.     (draw-to! (max-x) y)
  28.   )
  29.  
  30.   (goto-nw!)
  31.   (do ((x 0 (+ x 2)))
  32.       ((> x (max-x)) 0)
  33.     (set-color! (remainder (/ x 2) (max-color)))
  34.     (draw-to x (max-y))
  35.   )
  36.   (do ((y (+ (max-y) 1) (- y 2)))
  37.       ((< y 0) 0)
  38.     (set-color! (remainder (/ y 2) (max-color)))
  39.     (draw-to (max-x) y)
  40.   )
  41.  
  42.   (display "testing set-dot!") (newline)
  43.   (clear-graphics!)
  44.   (do ((x 0 (+ x 1)))
  45.       ((= x 100) 0)
  46.     (set-dot! (+ (random (max-x)) 1) (+ (random (max-y)) 1)
  47.           (+ (random (max-color)) 1))
  48.   )
  49.  
  50.   (display "testing draw with turn-to!") (newline)
  51.   (clear-graphics!)
  52.   (goto-center!)
  53.   (do ((x 0 (+ x 1)))
  54.       ((= x 100) 0)
  55.     (set-color! (+ (random (max-color)) 1))
  56.     (turn-to! (random 360))
  57.     (draw (random 50))
  58.   )
  59.  
  60.   (display "testing draw with turn-right") (newline)
  61.   (clear-graphics!)
  62.   (goto-center!)
  63.   (do ((x 0 (+ x 1)))
  64.       ((= x 100) 0)
  65.     (set-color! (+ (random (max-color)) 1))
  66.     (turn-right (random 90))
  67.     (draw (random 50))
  68.   )
  69.  
  70.   (display "testing draw with turn-left") (newline)
  71.   (clear-graphics!)
  72.   (goto-center!)
  73.   (do ((x 0 (+ x 1)))
  74.       ((= x 100) 0)
  75.     (set-color! (+ (random (max-color)) 1))
  76.     (turn-left (random 90))
  77.     (draw (random 50))
  78.   )
  79.  
  80.   (text-mode!)
  81. )
  82.  
  83.